/**
 *
 *
 */
class StringBuffer {
    private strings: Array<string>;

    public constructor() {
        this.strings = new Array<string>();
    }
	/**
	 * 追加字符串
	 */
    public append(str: string): StringBuffer {
        this.strings.push(str);
        return this;
    }
	/**
	 * 获取长度
	 */
    public get length(): number {
        var length = 0;
        for(var i = 0;i < this.strings.length;i++) {
            length += this.strings[i].length;
        }
        return length;
    }
	
	/**
	 * 清空
	 */
    public clear(): void {
        this.strings.length = 0;
    }
	

    /**
     * 转换为字符串
     * @returns {string}
     */
    public toString(): string {
        return this.strings.join("");
    }

    public static test(): void {
        var sb = new StringBuffer();

        sb.append("zzzzz").append("dfsasdsad");
        Log.d("StringBuffer:" + sb.toString() + ",length:" + sb.length);

        sb.clear();
        Log.d("StringBuffer clear,StringBuffer:" + sb.toString());
    }

}
